﻿using Abp.AutoMapper;
using Abp.Modules;
using Abp.Quartz;
using Abp.Reflection.Extensions;
using DualControl.Authorization;
using DualControl.CompanyInfos.Authorization;
using DualControl.ControlMeasures.Authorization;
using DualControl.CycleCheckTasks.Authorization;
using DualControl.EmergencyMeasures.Authorization;
using DualControl.HazardSources.Authorization;
using DualControl.Posts.Authorization;
using DualControl.RiskPoints.Authorization;

namespace DualControl
{
    [DependsOn(
        typeof(DualControlCoreModule), 
        typeof(AbpAutoMapperModule) , typeof(AbpQuartzModule))]
    public class DualControlApplicationModule : AbpModule
    {
        public override void PreInitialize()
        {

            //关闭审计日志
            Configuration.Auditing.IsEnabled = false;

            Configuration.Authorization.Providers.Add<DualControlAuthorizationProvider>();

            //岗位权限
            Configuration.Authorization.Providers.Add<PostAppAuthorizationProvider>();

            //风险点
            Configuration.Authorization.Providers.Add<RiskPointAppAuthorizationProvider>();

            //风险源
            Configuration.Authorization.Providers.Add<HazardSourceAppAuthorizationProvider>();

            //控制措施
           Configuration.Authorization.Providers.Add<ControlMeasureAppAuthorizationProvider>();
            //应急措施
            Configuration.Authorization.Providers.Add<EmergencyMeasureAppAuthorizationProvider>();

            
            //排查任务
            Configuration.Authorization.Providers.Add<CycleCheckTaskAppAuthorizationProvider>();

            //公司基本信息
            Configuration.Authorization.Providers.Add<CompanyInfoAppAuthorizationProvider>();


        }

        public override void Initialize()
        {
            var thisAssembly = typeof(DualControlApplicationModule).GetAssembly();

            IocManager.RegisterAssemblyByConvention(thisAssembly);

            Configuration.Modules.AbpAutoMapper().Configurators.Add(
                // Scan the assembly for classes which inherit from AutoMapper.Profile
                cfg => cfg.AddProfiles(thisAssembly)
            );
        }
    }
}
